package com.imy.luascript.app.ui.main.fragment.index;

import android.view.View;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.imy.common.base.adapter.ViewPagerAdapter;
import com.imy.common.view.slidetab.SlidingTabLayout;
import com.imy.luascript.R;
import com.imy.luascript.app.ui.dialog.createproject.CreateProjectDialog;
import com.imy.luascript.app.ui.main.fragment.demo.DemoFragment;
import com.imy.luascript.app.ui.main.fragment.project.ProjectFragment;
import com.imy.luascript.base.fragment.BaseLazyFragment;
import com.imy.luascript.viewmodel.BaseViewModel;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.OnClick;

public class IndexFragment extends BaseLazyFragment {
    @BindView(R.id.tab_layout)
    SlidingTabLayout tabLayout;
    @BindView(R.id.view_pager)
    ViewPager viewPager;
    @BindView(R.id.index_add_project_iv)
    ImageView indexAddProjectIv;

    @Override
    protected void onLazyLoadData() {

    }

    @Override
    protected void initView(View contentView) {
        List<String> list = new ArrayList<>();
        list.add("工程");
        list.add("示例");
        ViewPagerAdapter viewPagerAdapter = new ViewPagerAdapter(getChildFragmentManager(), getChildFragment(), list);
        viewPager.setAdapter(viewPagerAdapter);
        tabLayout.setViewPager(viewPager);
    }

    private List<Fragment> getChildFragment() {
        List<Fragment> list = new ArrayList<>();
        ProjectFragment projectFragment = new ProjectFragment();
        list.add(projectFragment);
        list.add(new DemoFragment());
        return list;
    }

    @Override
    protected BaseViewModel getViewModel() {
        return null;
    }

    @Override
    protected int getLayoutID() {
        return R.layout.fragment_index;
    }

    @OnClick(R.id.index_add_project_iv)
    public void onViewClicked() {
      new CreateProjectDialog((AppCompatActivity) self);
    }
}
